package top.lixunda.books3.util;

import org.springframework.stereotype.Component;

import java.util.Random;

@Component
public class StringUtils {

    private final Random random = new Random();

    public String randomFigure(int length){
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i < length; i++){
            String figures = "0123456789";
            builder.append(figures.charAt(random.nextInt(figures.length())));
        }
        return builder.toString();
    }

    public String randomString(int length){
        StringBuilder builder = new StringBuilder();
        for(int i = 0; i < length; i++){
            String strs = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            builder.append(strs.charAt(random.nextInt(strs.length())));
        }
        return builder.toString();
    }

}
